Ns-3 Configuration Using Eclipse
Navigation: Main -> ns-3 real-time -> Ns-3 Configuration Using Eclipse Download the NS3 source code 1) Install prerequisite packages. Paste this into the terminal: : sudo apt-get install -y build-essential vim python-dev mercurial bzr valgrind gsl-bin libgsl0-dev libgsl0ldbl flex bison tcpdump sqlite sqlite3 libsqlite3-dev libxml2 libxml2-dev libgtk2.0-0 libgtk2.0-dev vtun lxc uncrustify doxygen graphviz imagemagick texlive texlive-latex-extra texlive-generic-extra texlive-generic-recommended texlive-extra-utils texi2html texinfo python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev openmpi-bin mpi-default-dev eclipse 2) Download ns-3 sources using Mercurial. Run the following in the terminal: : cd workspace : hg clone http://chic.hg.sourceforge.net/hgweb/chic/ns-3-dev/ : You are now ready to build the ns-3 distribution. Configure Mercurial *Download Eclipse IDE for C++ developers from http://www.eclipse.org and install eclipse into your operation system. *Install mercurial eclipse plugin: :*Go to help -> Install New Software; :*Type http://cbes.javaforge.com/update in the "Work with" field and click "Add"; :*Check the box "Show only software applicable to target environment" :*Select the MercurialEclipse in the software list and "install" ( disregard the possible warning) *Suppose that the ns-3 project is downloaded to ~/workspace/ns-3-dev. *Restart Eclipse and choose a workspace directory.Mine is in ~/workspace. *Create a new empty C++ project with your preferred name and set the "Location" to the folder where it is downloaded ( mine is ~/workspace/ns-3-dev ).Note that there will be hg status following the project name in the Project Explorer. *Rightclick the project and go to the properties.In the Mercurial section,you may find the default repository has been set to http://chic.hg.sourceforge.net/hgweb/chic/ns-3-dev/ and by far the project is shared and you are now be able to pull, update, view history, etc under the "team" menu by rightclicking the project. You may also add a local repository location to the project in the Mercurial section. Configure Waf Builder *Rightclick the project and go to properties *Click on C/C++ build and configure the builder: :*Uncheck the box "Use default build command" :*Uncheck the box "Generate makefile automatically" :*Write ${workspace_loc:ns-3-dev}/waf 'in the build command :*Write '${workspace_loc:ns-3-dev} in the build directory :*Click on the behaviour tab and remove the `all` option behind the "Build(Incremental Build)" checkbox and write build *Before building the project, go to the ns-3-dev directory configure the waf build using the terminal( you can refer to Ns-3_Configuration_Using_the_Terminal for more options): ::./waf -d debug --enable-examples --enable-tests configure *Now you can "Build Project" '''or "Clean Project"' using Eclipse. Configure Debugger Suppose you want to debug a test application called "testprog". Here are the steps: *Click on the "Debug Configurations" option under the "Run" menu *Create a new configuration and choose a name for it *Click on the "Browse" button under the "Project" section and select the project ( It may be already selected by default ) *Click on the "Search Project" button under the "C/C++ Application" section and type the name of the application ( testprog in our case) *Go into the "Environment" tab and click on "New" to create a new variable *Type under the Name field '''LD_LIBRARY_PATH' *Type under the Value field ${workspace_loc:ns-3-dev}/build *Be sure the "Append environment to native environment" is selected *Click on Apply and on Debug if you want to immediately debug the application Configure To Run From Eclipse 'Configure External Runner' *Add an external builder (Run->External Tools->External Tools Configuration) and add a new configuration :*Location = your waf location (i.e. ${workspace_loc:/ns-3-dev/waf ) :*Working Directory = your ns3 directory (i.e.' ${workspace_loc:/ns-3-dev}' ) :*Arguments = '--run "${string_prompt}"' *Then you can run your program (with arguments) with the new created external builder.For example,input the value hello-simulator 'and Eclipse will run the "hello simulator" program. 'Configure Internal Runner You can also use the internal runner to run any C++ Application generated. *Run -> Run Configurations *New launch Configuration and you can type the application name in the "Name" section (i.e. "hello-simulator" here ) :*On the Main tab: Project = your project; C/C++ Application: click "Search Project" to find the application ( i.e. ns3-dev-hello-simulator-debug here ) :*On the Environment tab, create the LD_LIBRARY_PATH variable as ${workspace_loc:ns-3-dev}/build *Run -> Debug Configurations *On the Debugger tab of "hello-simulator", Shared Library tab, Add the ns-3-dev/build directory, so all the libraries can be loaded. *Then you can run your application with the new created internal configuration: Run -> Run Configurations -> "hello-simulator" -> Run Reference 1. HOWTO configure eclipse with ns-3